********************************************************************************************************************************
***   Replication file for:                                                                                                  ***
***   Berbee, P., Braun, S. T. and Franke, R. (2024). Reversing Fortunes of German Regions, 1926-2019. JoEG				     ***
***   							                                                                                             ***
***   SCRIPT: 	3b_industrialization_and_development_rb.do				   														 ***																														  ***
***   PURPOSE: 	Generates results at the district (Regierungsbezirke) level as reported in Appendix Table A-4.				 ***
***																															 ***
***	  Tables:	Panel E of Table A-4																						 ***
***	  Figures:	-																										 	 ***
********************************************************************************************************************************


********************************************************************************************************************************
*** A. Prepare district-level dat
********************************************************************************************************************************

********************************************************************************************************************************
*** GDP 1957-2019
********************************************************************************************************************************


** Importing GDP data for years 1957-1992
foreach file in 1_Data_RegBez1957 1_Data_RegBez1961 1_Data_RegBez1964 1_Data_RegBez1966 2_Data_RegBez1961 2_Data_RegBez1968 2_Data_RegBez1970 3_Data_RegBez1970 3_Data_RegBez1972 3_Data_RegBez1974 4_Data_RegBez1978 4_Data_RegBez1980 5_Data_RegBez1980 5_Data_RegBez1992 {
import excel "$reversing/data/`file'.xlsx", firstrow clear

* Harmonize inconsistent variable names over time
rename Wohn*ev* population
*rename R*BIP* realGDP 
rename BIP* GDP* 

*drop A RB66_ID
rename T_ID rb_id
destring rb_id, replace
keep rb_id GDP* pop*

* Reshape dataset to long format -> panel 
reshape long GDP, i(rb_id) j(year) 

* Create a variable for the number of DESTATIS publication ("gebietsstand")
gen gebietsstand=substr("`file'",1,1) 
destring gebietsstand, replace

* Harmonize population measure
replace population=population*1000 if inlist(gebietsstand,4,5) 

* Save yearly files seperately
save "$reversing/processed/intermediate/`file'.dta", replace 
}


** Import GDP and population data for years 2000-2019
foreach var in BIP EW {
import excel "$reversing/data/9_Data_RegBez`var'1992_2019.xlsx", firstrow clear

drop A RB66_ID
rename T_ID rb_id
destring rb_id, replace

gen gebietsstand=7

reshape long X, i(rb_id) j(year) // reshape dataset to long format -> panel 
if "`var'"=="BIP" {
rename X GDP
}
if "`var'"=="EW" {
rename X population
replace population=population*1000
}
drop if inrange(year,1992,1999)
save "$reversing/processed/intermediate/`var'RegBez0019.dta", replace 
}


** Import GDP and population data for years 1992-2009
foreach var in BIP EW {
import excel "$reversing/data/7_Data_RegBez`var'1992_2009.xlsx", firstrow clear 

drop A RB66_ID
rename T_ID rb_id
destring rb_id, replace

gen gebietsstand=6

reshape long X, i(rb_id) j(year) // reshape dataset to long format -> panel 
if "`var'"=="BIP" {
rename X GDP 
}
if "`var'"=="EW" {
rename X population
replace population=population*1000
}
save "$reversing/processed/intermediate/`var'RegBez9209.dta", replace 
}


** Import GDP deflator
import excel "$reversing/data/gdp_deflator.xlsx",sheet("Tabelle1") firstrow clear
save "$reversing/processed/intermediate/GDPdeflator.dta", replace



*** Merging GDP data 

use "$reversing/processed/intermediate/EWRegBez9209.dta", clear 
merge 1:1 rb_id year using"$reversing/processed/intermediate/BIPRegBez9209.dta", nogen

append using "$reversing/processed/intermediate/EWRegBez0019.dta"
merge 1:1 rb_id year gebietsstand using"$reversing/processed/intermediate/BIPRegBez0019.dta", nogen update

foreach file in 1_Data_RegBez1957 1_Data_RegBez1961 1_Data_RegBez1964 1_Data_RegBez1966 2_Data_RegBez1961 2_Data_RegBez1968 2_Data_RegBez1970 3_Data_RegBez1970 3_Data_RegBez1972 3_Data_RegBez1974 4_Data_RegBez1978 4_Data_RegBez1980 5_Data_RegBez1980 5_Data_RegBez1992 {
append using "$reversing/processed/intermediate/`file'.dta"
}

sort rb_id year gebietsstand
save "$reversing/processed/intermediate/GDP_RegBez.dta", replace

********************************************************************************************************************************
*** Turnover 1926, 1935, 1950, 1955
********************************************************************************************************************************


*** 1926

import excel "$reversing/data/turnover1926_RegBez.xlsx", sheet("Data") firstrow clear

drop A RB66_ID
rename T_ID rb_id
destring rb_id, replace

rename huv_u h_u


* Create some globals that facilitate labeling of variables
global l_in "insgesamt"
global l_l "Landwirtschaft (insges.)"
global l_lk "Landwirtschaft (Kleinums.)"
global l_i "Industrie"
global l_h "Handel und Transport"
global l_s "Staat/öffentl.Hand"

global m_veran "Veranlagte"
global m_u "Umsatz (1000RM)"
global m_stbel "Steuerbelastete"
global m_st "Umstatzsteuer(1000RM)"


* label variables and change names
foreach sect in in l lk i h s{
foreach var in veran u stbel st{
label var `sect'_`var' "${m_`var'} ${l_`sect'} (1926)"
rename `sect'_`var' `sect'_`var'_1926
}
}

gen turnover=in_u_1926
gen turnover_agr=l_u_1926
gen turnover_ind=i_u_1926
gen turnover_trade=h_u_1926
gen turnover_public=s_u_1926


* Rename and create matching variables
rename pop1925 population

gen year=1926

*** Save data
keep rb_id population turnover year
destring rb_id, replace
sort rb_id

save "$reversing/processed/intermediate/turnover1926_RegBez.dta",replace


*** 1935

*** Import data on population 1939
import excel "$reversing/data/Population_1939_RegBez.xlsx", sheet("Data") firstrow clear

* Rename 
rename pop population

drop A RB66_ID
rename T_ID rb_id
destring rb_id, replace

*** Save population data
keep rb_id population
sort rb_id

save "$reversing/processed/intermediate/population1939_RegBez.dta",replace


*** Import data
import excel "$reversing/data/turnover1935_RegBez.xlsx", sheet("Data") firstrow clear

* Rename and create matching variables
drop A RB66_ID
rename T_ID rb_id
destring rb_id, replace

gen turnover=in_u

* Merge with 1939 population data (as we don't have population data for 1935)
merge 1:1 rb_id using "$reversing/processed/intermediate/population1939_RegBez.dta"

gen year=1935

*** Save data
keep rb_id turnover population year

save "$reversing/processed/intermediate/turnover1935_RegBez.dta",replace


*** 1950


** Import data

import excel "$reversing/data/turnover1950_RegBez.xlsx", sheet("Data") firstrow clear

keep T_ID insg_u bev
rename T_ID rb_id
destring rb_id, replace

rename insg_u turnover
*rename land_u turnover_agr
rename bev population
gen year = 1950

** Save data

sort rb_id
save "$reversing/processed/intermediate/turnover1950_RegBez.dta",replace


*** 1955

** Import data

import excel "$reversing/data/turnover1955_RegBez.xlsx", sheet("Data") firstrow clear

keep T_ID insg_u pop_to_stat
rename T_ID rb_id
destring rb_id, replace

rename insg_u turnover
*rename land_u turnover_agr
rename pop_to_stat population
gen year = 1955

** Save data

sort rb_id
destring rb_id, replace
save "$reversing/processed/intermediate/turnover1955_RegBez.dta",replace



********************************************************************************************************************************
*** Employment census 1882
********************************************************************************************************************************

* Labels 1882 census 2-digit sectors

global dLandw Landw./Thierzucht/Gärtnerei
global dForstw Forstwirtschaft/Jagd
global dFische Fischerei
global dBergbau Bergbau/Hütten/Salinen
global dTorf Torfgräberei/-bereitung
global dSteine Ind.d.Steine und Erden
global dMetall Metallverarbeitung (außer Eisen) 
global dEisen Eisenverarbeitung
global dMaschinen Fert.v.Maschinen/Werkz./Apparaten
global dChemisch Chemische Industrie
global dForstwNeben Organ.Leuchtst./Fette/Öle/Firnisse
global dTextil Textilindustrie
global dPapierLeder Papier-/Lederindustrie
global dHolz Holz/Schnitzstoffe
global dNahrung Nahrung/Genussmittel
global dBekleidung Bekleidung/Reinigung
global dBaugewerbe Baugewerbe
global dPolygr Polygraphisches Gewerbe
global dKunst Künstler/künstlerisch. Gewerbe
global dFabrikanten Fabrikanten/Fabrikarbeiter
global dHandel Handelsgewerbe
global dVersicherung Versicherungsgewerbe
global dLandverkehr Landverkehr
global dWasserverkehr Wasserverkehr
global dBeherbergung Beherbergung/Erquickung
global dHauslDienstl Häusl.Dienstleist./Tagelöhner
global dStaats Staat/Gemeinden/Kirchen/freie Berufe
global dOhneBeruf Ohne Beruf/Berufsangabe
global dGesamt Gesamtbevölkerung


*** Create sector shares in persons employed
import excel "$reversing/data/Berufszaehlung_1882_RegBez.xlsx", sheet("Data") firstrow clear

drop A RB66_ID
rename T_ID rb_id
destring rb_id, replace

foreach var of varlist Landw-Gesamt{
rename `var' emp_`var'_1882	
label var emp_`var'_1882 "Erwerbstätige in ${d`var'} (1882)"
}

save "$reversing/processed/intermediate/occ_census1882_emp_RegBez.dta",replace


*** Create sector shares per total population (including servants and family)

*** Import data on selected 2-digit industries
import excel "$reversing/data/Berufszaehlung_1882_Summe_RegBez.xlsx", sheet("Data") firstrow clear

rename T_ID rb_id
destring rb_id, replace

drop A RB66_ID Forstw Fische Torf Steine ForstwNeben PapierLeder Holz Nahrung Bekleidung Baugewerbe Polygr Kunst Fabrikanten Versicherung Landverkehr Wasserverkehr Beherbergung HauslDienstl Staats OhneBeruf
foreach var of varlist Landw-Gesamt{
rename `var' pop_`var'_1882	
label var pop_`var'_1882 "Population in ${d`var'} (1882)"
}

save "$reversing/processed/intermediate/occ_census1882_pop_RegBez.dta",replace


********************************************************************************************************************************
*** Instrumental variables, Daudin
********************************************************************************************************************************

*** Take average over labor market regions within a district

use "$reversing/processed/intermediate/iv_daudin.dta", clear
merge 1:1 labor_market_id using "$reversing/processed/intermediate/labor_market_ids.dta"
drop _merge
merge 1:1 labor_market_id using "$reversing/processed/intermediate/spatialcontrols.dta"
drop _merge
merge 1:1 labor_market_id using "$reversing/processed/intermediate/occ_census1882_pop.dta"
drop _merge

keep labor_market_id rb_id coal_access1_daudin land_access1_daudin pop_Gesamt_1882 area

foreach x in coal_access1_daudin land_access1_daudin {
bysort rb_id: egen `x'_rb = mean(`x')
}

sort rb_id
drop if rb_id == rb_id[_n-1]

keep rb_id coal_access1_daudin_rb land_access1_daudin_rb 

label var coal_access1_daudin_rb "Coal area (sqm) weighted by Daudin transport costs, averaged"
label var land_access1_daudin_rb "Land access weighted by Daudin transport costs, averaged"

save "$reversing/processed/intermediate/iv_averaged_RegBez.dta", replace 


********************************************************************************************************************************
*** Predevelopment index
********************************************************************************************************************************


** Import data
use "$reversing/data/cities_RegBez.dta", clear

rename labor_market_id rb_id
destring rb_id, replace

** Save data
save "$reversing/processed/intermediate/preindustrial_RegBez.dta", replace


********************************************************************************************************************************
*** Spatial controls
********************************************************************************************************************************


*** Import data

import excel "$reversing/data/SpatialControls_RegBez.xlsx", sheet("Data") firstrow clear

keep RB66_ID D lat Area

rename RB66_ID rb_id
destring rb_id, replace

** Rename and label

rename Area area
label var area "Area (sq km)"

rename D longitude 
label var longitude "Longitude"

rename lat latitude 
label var latitude "Latitude"

sort rb_id

save "$reversing/processed/intermediate/spatialcontrols_RegBez.dta",replace






********************************************************************************************************************************
*** B. Prepare Dataset
********************************************************************************************************************************


*** i. Merge data set

use "$reversing/processed/intermediate/GDP_RegBez.dta", clear 


* Merge with data on 1926, 1935, 1950, and 1955 turnover
append using "$reversing/processed/intermediate/turnover1926_RegBez.dta"
append using "$reversing/processed/intermediate/turnover1935_RegBez.dta" 
append using "$reversing/processed/intermediate/turnover1950_RegBez.dta" 
append using "$reversing/processed/intermediate/turnover1955_RegBez.dta" 


* Merge dataset with GDP deflator
merge m:m year using "$reversing/processed/intermediate/GDPdeflator.dta", nogen keep(match master)

* Merge with data on instrument
merge m:1 rb_id using "$reversing/processed/intermediate/iv_averaged_RegBez.dta" 
drop _merge


* Merge with data on 1882 employment census
	
merge m:1 rb_id using "$reversing/processed/intermediate/occ_census1882_emp_RegBez.dta"
drop _merge

merge m:1 rb_id using "$reversing/processed/intermediate/occ_census1882_pop_RegBez.dta"
drop _merge

* Merge with pre-industrial development data

merge m:1 rb_id using "$reversing/processed/intermediate/preindustrial_RegBez.dta"
drop _merge

* Merge with area data

merge m:1 rb_id using "$reversing/processed/intermediate/spatialcontrols_RegBez.dta"
drop _merge

*** ii. Create and label variables

*** Drop Saarland (for which we do not have information early on and after WW2)
drop if rb_id == 100 

*** GDP and turnover statistics ************************************************

** Population

recode population 0 = .

* Real and per capita values 
foreach var in GDP { 
gen real`var'=100*`var'/DeflatorDM if inlist(gebietsstand,1,2,3,4,5)
replace real`var'=100*`var'/DeflatorEUR if inlist(gebietsstand,6,7)
gen pc`var'=1000000*`var'/population
gen realpc`var'=1000000*real`var'/population
}

* GDP ranking
bysort year gebietsstand: egen pcGDP_ranking=rank(pcGDP)

* Create turnover per capita and ranking
gen realturnover = (100*turnover/DeflatorDM) 
label var realturnover "Real turnover (in 1992 prices)"

gen turnoverpc = (1000 * turnover / population ) if year != 1955
replace turnoverpc = (1000000 * turnover / population ) if year == 1955
label var turnoverpc "Turnover per capita"

gen realturnoverpc = (1000 * realturnover / population ) if year != 1955
replace realturnoverpc = (1000000 * realturnover / population ) if year == 1955
label var realturnoverpc "Real turnover per capita (in 1992 prices)"

sort year gebietsstand rb_id
bysort year gebietsstand: egen turnoverpc_ranking=rank(turnoverpc)
label var turnoverpc_ranking "Turnover per capita ranking"

drop pcGDP DeflatorDM DeflatorEUR 

* Rank percentile (Since 1957 based on GDP ranking, for earlier years on turnover ranking)
gen rank=pcGDP_ranking
replace rank=turnoverpc_ranking if pcGDP_ranking==.
xtile rank_perc = rank, nq(100) 
label var rank_perc "Percentile rank in income per capita distribution"
drop rank

* Change in percentile rank 
gen help = rank_perc if year == 1926
bysort rb_id: egen rank_perc_1926 = mean(help)
drop help

gen help = rank_perc if year == 1957
bysort rb_id: egen rank_perc_1957 = mean(help)
drop help

gen help = rank_perc if year == 2019
bysort rb_id: egen rank_perc_2019 = mean(help)
drop help

gen change_perc_2619 = rank_perc_2019 - rank_perc_1926
label var change_perc_2619 "Percentile rank change in income per capita distribution, 1926-2019" 

gen change_perc_5719 = rank_perc_2019 - rank_perc_1957
label var change_perc_5719 "Percentile rank change in income per capita distribution, 1957-2019" 

drop rank_perc_1926 rank_perc_1957 rank_perc_2019

********************************************************************************
*** 1882 Industry structure ****************************************************


* Create employment shares of 2-digit industries
foreach var in Landw Forstw Fische Bergbau Torf Steine Metall Eisen Maschinen Chemisch ForstwNeben Textil PapierLeder Holz Nahrung Bekleidung Baugewerbe Polygr Kunst Fabrikanten Handel Versicherung Landverkehr Wasserverkehr Beherbergung HauslDienstl Staats OhneBeruf {
gen empshare_`var'_1882=emp_`var'_1882/emp_Gesamt_1882
label var empshare_`var'_1882 "Empl. share in ${d`var'} (1882)"
}

* Create employment share in industry occupations (these are employment shares - excluding family members)
gen empshare_ind_1882 = (empshare_Bergbau_1882 + empshare_Torf_1882 + empshare_Steine_1882 + empshare_Metall_1882 + empshare_Eisen_1882 + empshare_Maschinen_1882 + empshare_Chemisch_1882 + empshare_ForstwNeben_1882 + empshare_Textil_1882 + empshare_PapierLeder_1882 + empshare_Holz_1882 + empshare_Nahrung_1882) 
egen empshare_ind_1882_std=std(empshare_ind_1882), by(year gebietsstand)

label var empshare_ind_1882 "Employment share of mining and industry (excl. Gewerbe), 1882"
label var empshare_ind_1882_std "Employment share of mining and industry (excl. Gewerbe), 1882 (standardized)"



********************************************************************************
*** Create indicators for preindustrial development ****************************

gen town_1800_perarea = town_1800 / area
gen town_1700_perarea = town_1700 / area


********************************************************************************
*** Log of instrument / land access						    ********************


gen log_coal_access1_dau_rb = log(coal_access1_daudin_rb)
gen log_land_access1_dau_rb = log(land_access1_daudin_rb) 

label var log_coal_access1_dau_rb "Coal area (sqm) weighted by Daudin transport costs (logs, averaged over LLMs)"
label var log_land_access1_dau_rb "Land access weighted by Daudin transport costs (logs, averaged over LLMs)"


********************************************************************************
*** C. Label and order *********************************************************

sort rb_id year

gen ___IDs__________________________=.
order ___IDs__________________________ rb_id gebietsstand year, first
label var gebietsstand "# of Destatis publication GDP data is based on" 
label var rb_id "District ID"
label var year "Year"

gen ___GDP_Turnover_________________ = .
order ___GDP_Turnover_________________ GDP population realGDP realpcGDP pcGDP_ranking turnover turnoverpc realturnover realturnoverpc turnoverpc_ranking rank_perc change_perc_2619 change_perc_5719, after(year)
label var GDP "Nominal GDP (currency as in destatis publications)"
label var turnover "Nominal turonver (currency as in Stat. Reichsamt publications)"
label var population "Population"
label var realGDP "Real GDP (in 1992 DM)"
label var realpcGDP "Real GDP per capita (in 1992 DM)"
label var pcGDP_ranking "GDP per capita rank"

gen ___Instruments_________________ =.
order ___Instruments_________________ log_coal_* coal_*, after(change_perc_5719)

rename log_coal_access1_dau_rb log_coal_access1
rename log_land_access1_dau_rb log_land_access1 
 
gen ___Spatial_____________ = .
order ___Spatial_____________ area longitude latitude log_land_* land_*, after(coal_access1_daudin_rb)
drop hanse

gen ___1882_Census________________ = .
rename pop_Gesamt_1882 pop_total_1882
label var pop_total_1882 "Population in 1882"

order ___1882_Census________________ empshare_ind_1882 empshare_ind_1882_std pop_total_1882, after(land_access1_daudin_rb)
drop empshare_Landw_1882- empshare_OhneBeruf_1882 emp_*1882
drop pop_Landw_1882 - pop_Handel_1882

gen ___Preindustrial_development___ = .
order ___Preindustrial_development___ town_1800_perarea town_1700_perarea, after(pop_total_1882) 
label var town_1800_perarea "No of towns per area in 1800"
label var town_1700_perarea "No of towns per area in 1700"

drop cities_total town_1800 town_1700 markets_1800 markets_1700 market_places_1700 market_places_1800 new_const_1700_1800 new_const_1700_1750  


********************************************************************************
*** Part D. Drop superfluous observations                                    ***

********************************************************************************
*** Keep always most recent GDP estimate for a year ****************************
*** Exception: 1961 so as to use consistent source for 1957-66
*** Exception: 1992 so as to avoid a break in datasource 1980-1992

keep if ///
inlist(year,1926,1935,1950,1955) | ///
gebietsstand==1 & inrange(year,1957,1966) | ///
gebietsstand==2 & inrange(year,1968,1968) | ///
gebietsstand==3 & inrange(year,1970,1974) | ///
gebietsstand==4 & year==1978 | ///
gebietsstand==5 & inrange(year,1980,1992) | ///
gebietsstand==6 & inrange(year,1993,1999) | ///
gebietsstand==7 & inrange(year,2000,2019)


* Order and save

sort rb_id year
save "$reversing/processed/workingdataset_rb.dta", replace

********************************************************************************
*** Analysis
********************************************************************************

************
*** Table A-4: Robustness checks of 2SLS estimates: Other checks and specifications, Panel E

use "$reversing/processed/workingdataset_rb.dta", clear

** Create variables for percentile ranks for 1926, 1957, 2019

gen help = rank_perc if year == 1926
bysort rb_id: egen rank_perc_1926 = mean(help)
drop help

gen help = rank_perc if year == 1957
bysort rb_id: egen rank_perc_1957 = mean(help)
drop help

gen help = rank_perc if year == 2019
bysort rb_id: egen rank_perc_2019 = mean(help)
drop help

** Choose covariates
local covariates log_land_access1 town_1700_perarea


** Percentile ranks
** Change in percentile ranks: 1926-2019 (Column 1) and 1957-2019 (Column 2)
foreach year in 26 57 {
eststo twosls_change`year'19: ivreg2 change_perc_`year'19 (empshare_ind_1882_std=log_coal_access1) `covariates' if year == 2019, first robust
eststo twosls_change`year'19_co: acreg change_perc_`year'19 (empshare_ind_1882_std=log_coal_access1) `covariates' if year == 2019,  latitude(latitude) longitude(longitude) spatial bartlett distcutoff(100) 

}

** Ranking of GDP per capita 1926 (Column 3), 1957 (Column 4), and 2019 (Column 5)
foreach year in 1926 1957 2019 {
eststo twosls_`year': ivreg2 rank_perc (empshare_ind_1882_std=log_coal_access1) `covariates' if year == `year', first cluster(rb_id)
eststo twosls_`year'_co: acreg rank_perc (empshare_ind_1882_std=log_coal_access1) `covariates' if year == `year',  latitude(latitude) longitude(longitude) spatial bartlett distcutoff(100) 
}



esttab twosls_change2619_co twosls_change5719_co twosls_1926_co twosls_1957_co twosls_2019_co using"$reversing/results/tables/tabA4_panelE.tex", keep (empshare_ind_1882_std) coeflabels(empshare_ind_1882_std "Percentile rank as dependent variable") cells(b(star fmt(2)) se(fmt(2) par("(" ")"))) nomtitles nonum noobs collabel(none)  star(* 0.10 ** 0.05 *** 0.01) plain fragment booktabs replace

esttab twosls_change2619 twosls_change5719 twosls_1926 twosls_1957 twosls_2019 using"$reversing/results/tables/tabA4_panelE.tex", keep(empshare_ind_1882_std) coeflabels(empshare_ind_1882_std " ") cells(se(fmt(2) par("[" "]")))  nomtitles nonum noobs collabel(none) plain fragment booktabs append


** Log income per capita

gen log_income = log(realpcGDP)
replace log_income = log(realturnoverpc) if year == 1926

gen help = log_income if year == 1926
bysort rb_id: egen log_income_1926 = mean(help)
drop help

gen help = log_income if year == 1957
bysort rb_id: egen log_income_1957 = mean(help)
drop help

gen help = log_income if year == 2019
bysort rb_id: egen log_income_2019 = mean(help)
drop help

gen change_log_income_2619 = log_income_2019 - log_income_1926 
gen change_log_income_5719 = log_income_2019 - log_income_1957 


** Change in log income ranks: 1926-2019 (Column 1) and 1957-2019 (Column 2)
foreach year in 26 57 {
eststo twosls_change`year'19: ivreg2 change_log_income_`year'19 (empshare_ind_1882_std=log_coal_access1) `covariates' if year == 2019, first robust
eststo twosls_change`year'19_co: acreg change_log_income_`year'19 (empshare_ind_1882_std=log_coal_access1) `covariates' if year == 2019,  latitude(latitude) longitude(longitude) spatial bartlett distcutoff(100) 

}

** Ranking of GDP per capita 1926 (Column 3), 1957 (Column 4), and 2019 (Column 5)
foreach year in 1926 1957 2019 {
eststo twosls_`year': ivreg2 log_income (empshare_ind_1882_std=log_coal_access1) `covariates' if year == `year', first cluster(rb_id)
eststo twosls_`year'_co: acreg log_income (empshare_ind_1882_std=log_coal_access1) `covariates' if year == `year',  latitude(latitude) longitude(longitude) spatial bartlett distcutoff(100) 
}

** Table

esttab twosls_change2619_co twosls_change5719_co twosls_1926_co twosls_1957_co twosls_2019_co using"$reversing/results/tables/tabA4_panelE.tex", keep (empshare_ind_1882_std) coeflabels(empshare_ind_1882_std "Log income as dependent variable") cells(b(star fmt(2)) se(fmt(2) par("(" ")"))) nomtitles nonum noobs collabel(none)  star(* 0.10 ** 0.05 *** 0.01) plain fragment booktabs append

esttab twosls_change2619 twosls_change5719 twosls_1926 twosls_1957 twosls_2019 using"$reversing/results/tables/tabA4_panelE.tex", keep(empshare_ind_1882_std) coeflabels(empshare_ind_1882_std " ") cells(se(fmt(2) par("[" "]")))  nomtitles nonum noobs collabel(none) plain fragment booktabs append





*** EOF












